<template>
  <div>
    <el-col :span="4" :xs="24">
      <HeadTree :dataList="treeData" @chooseTreeData="chooseTree" />
    </el-col>
  </div>
</template>

<script>
import HeadTree from "@/components/HeadTree/index";

export default {
  components: {HeadTree},
  props: {
    dataList: {
      type: Array,
      default: ()=>[]
    }
  },
  data() {
    return {
      treeData: [
        {
          label: '服务方列表',
          id: '',
          supplierType: '',
          children: []
        }
      ]
    }
  },
  watch: {
    dataList: {
      handler(val) {
        if(val && val.length > 0) {
          this.getTreeData(val);
        }
      }
    }
  },
  methods: {
    getTreeData(val) {
      this.treeData[0].children = val.map(item => {
        return {
          ...item,
          label: item.supplierName,
          id: item.supplierId,
          supplierType: item.supplierType
        }
      })
    },

    chooseTree(data) {
      this.$emit("chooseTreeData", data);
    }
  }

}
</script>

<style scoped>

</style>
